{% extends "base.html" %}

{% load crispy_forms_tags i18n permissions translations %}

{% block breadcrumbs %}
  {% path_object_breadcrumbs path_object %}
{% endblock breadcrumbs %}

{% block content %}
  {% perm 'translation.add' object as user_can_add_translation %}
  {% perm 'translation.add_more' object as user_can_add_more_translation %}

  {% if user_can_add_translation %}

    <div class="tab-pane" id="newlang">

      <form action="{% url 'new-language' path=object.get_url_path %}" method="post">
        {% csrf_token %}
        <div class="card">
          <div class="card-header">
            <h4 class="card-title">{% translate "Start new translation" %}</h4>
          </div>
          <div class="card-body">
            {% if object.new_lang == 'url' and not can_add %}
              <p>
                <a href="{{ object.project.get_absolute_url }}#information">{% translate "The translator instructions has info on how to start translating into other languages." %}</a>
              </p>
            {% else %}
              <p>
                {% translate "Please choose the language you want to translate to." %}
                {% if object.file_format_create_style == "create" %}
                  {% if object.new_base %}
                    {# Bilingual formats #}
                    {% blocktranslate with new_base=object.new_base %}A translation file will be created based on <code>{{ new_base }}</code> with all strings untranslated.{% endblocktranslate %}
                  {% else %}
                    {# Monolingual formats, for example JSON or Android #}
                    {% translate "An empty translation file will be created and new strings added as they are translated." %}
                  {% endif %}
                {% elif object.file_format_create_style == "copy" %}
                  {# Documents, for example ODT, HTML, IDML #}
                  {% if object.new_base %}
                    {% blocktranslate with new_base=object.new_base %}A translation file will be created as a copy of <code>{{ new_base }}</code> with all strings marked as "Needs editing" and replaced as they are translated.{% endblocktranslate %}
                  {% else %}
                    {# Should not happen #}
                    Create style: {{ object.file_format_create_style }}
                  {% endif %}
                {% elif object.file_format_create_style == "directory" %}
                  {# App store metadata #}
                  {% translate "An empty directory will be created for translations, with individual files created as strings are translated." %}
                {% else %}
                  {# Should not happen #}
                  Create style: {{ object.file_format_create_style }}
                {% endif %}
              </p>
              {% if object.new_lang == 'contact' and not can_add %}
                <p>{% translate "Project maintainers are notified of this request, prompting them to add the language manually." %}</p>
              {% endif %}
              {{ form|crispy }}
              {% if user_can_add_more_translation %}
                {% if contact_form != "disabled" %}
                  <p class="help-block">
                    <a href="{% url 'contact' %}?t=lang">{% translate "Can't find your language in the list above?" %}</a>
                  </p>
                {% endif %}
              {% else %}
                <p class="help-block">
                  {% translate "This list includes only basic languages. Please contact project maintainers to add others." %}
                </p>
              {% endif %}
            </div>
            <div class="card-footer">
              {% if object.new_lang == 'contact' %}
                <input class="btn btn-primary"
                       type="submit"
                       value="{% translate "Request new translation" %}" />
              {% else %}
                <input class="btn btn-primary"
                       type="submit"
                       value="{% translate "Start new translation" %}" />
              {% endif %}
            {% endif %}
          </div>
        </div>
      </form>

    </div>
  {% else %}
    <p>
      {% if user_can_add_translation.reason %}
        {{ user_can_add_translation.reason }}
      {% else %}
        {% translate "You don't have permission to start a new translation" %}
      {% endif %}
    </p>
  {% endif %}

{% endblock content %}
